package Text38;

import java.util.*;

public class Main {
    /*
       (1) C(n, 1) = n --> 对应从左向右看斜着的第二列！ ---> 一定有解
    (2)由于杨辉三角左右对称（C(a, b) == C(a, a-b)），又由于找第一次出现，因此一定在左边
                    循环下面16个斜行
                    👇👇
            1  ---> C(0, 0)
          1
        1   2  ---> C(2, 1)
      1   3                             ---> C(2n, n)
    1   4   6  ---> C(4, 2)
  1   5   10
1   6   15  20 ---> C(6, 3)
   (3) n最大1e9，C(34, 17) > 1e9, C(32, 16) < 1e9，因此只要枚举前16个斜行即可！

     (4)C(r, k)对应的顺序值为：(r + 1) * r / 2 + k + 1
*/
    static int n;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 16; ; i--) {
            if (check(i)) {
                break;
            }
        }
    }

    private static boolean check(int k) {
        long l = 2 * k, r = Math.max(l, n);
        while (l<r) {
            long mid = l + r >> 1;
            if (C(mid, k) >= n) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        if (C(r, k) == n) {
            System.out.println(r * (r + 1) / 2 + k + 1);
            return true;
        }
        return false;
    }

    private static long C(long  x, int k) {
        long res = 1;
        for (long i = x, j = 1; j <= k; i--, j++) {
            res = res * i / j;
            if (res > n) {
                return res;
            }
        }
        return res;
    }

}